from random import randint
import time

def quick_sort(num_list):
    if len(num_list) < 2:
        return num_list

    middle = num_list[0]
    smaller = []
    larger = []
    for i in num_list[1:]:
        if i < middle:
            smaller.append(i)
        else:
            larger.append(i)

    return quick_sort(smaller) + [middle] + quick_sort(larger)

if __name__ == '__main__':
    start = time.time()
    num = 10000000
    alist = [randint(1, num) for i in range(num)]
    print(alist[:100])
    print(quick_sort(alist)[:100])
    end = time.time()
    print('duration: %s' % str(end-start))